package com.geek.alert.beans;

import java.util.stream.Stream;

public class AlertRule {
    private MatchedRule matchedRule;

    public AlertRule(MatchedRule matchedRule) {
        this.matchedRule = matchedRule;
    }

    public MatchedRule.ApiRule getMatchedRule(String api) {
        return Stream.of(matchedRule.getApiRules())
                .filter(s -> s.getApi().equals(api))
                .findFirst().orElseThrow(() -> new RuntimeException("api未配置"));
    }
}
